Skip to content

chore: add prettier auto-format hook for Claude Code#1037

Merged
dqnykamp merged 3 commits intoDoenet:mainfrom
dqnykamp:chore/auto-format-hook
May 3, 2026
Merged

chore: add prettier auto-format hook for Claude Code#1037
dqnykamp merged 3 commits intoDoenet:mainfrom
dqnykamp:chore/auto-format-hook

Conversation

@dqnykamp
Copy link
Copy Markdown
Member

@dqnykamp dqnykamp commented May 1, 2026

Summary

  • Adds .claude/settings.json with a PostToolUse hook that runs prettier --write --ignore-unknown on files after Write/Edit/MultiEdit/NotebookEdit operations.
  • Enforces automatic formatting rather than relying on the agent to read and follow the "format with prettier before committing" instruction in AGENTS.md — which was missed in refactor(worker-javascript): extract Phase 1 helpers from Core.js #1036.
  • Hook respects .prettierignore (auto-discovered by prettier) and only formats files inside the project directory.

Test plan

  • After merging, contributors using Claude Code on this repo should open /hooks once (or restart Claude Code) so the new settings take effect.
  • Verify by editing a .ts/.js file with formatting violations and confirming it gets auto-formatted on save.
  • Confirm .md and other ignored paths are skipped (already covered by .prettierignore).

🤖 Generated with Claude Code

Adds .claude/settings.json with a PostToolUse hook that runs prettier on
files after Write/Edit/MultiEdit/NotebookEdit operations. Ensures code is
formatted automatically rather than relying on the agent to follow the
"format with prettier before committing" instruction in CLAUDE.md (which
was missed in PR Doenet#1036).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

⚠️ No Changeset found

Latest commit: 834aee0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Claude Code hook configuration to automatically run Prettier after file write/edit operations, aiming to keep agent-driven edits consistently formatted in this repo.

Changes:

  • Add .claude/settings.json defining a PostToolUse hook for Write|Edit|MultiEdit|NotebookEdit.
  • Hook runs npx --no-install prettier --write --ignore-unknown on the edited file path (when it appears to be under $PWD).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .claude/settings.json
Comment thread .claude/settings.json Outdated
Comment thread .claude/settings.json Outdated
dqnykamp and others added 2 commits May 3, 2026 00:23
- Redirect jq stderr to suppress noise on missing/erroring jq
- Guard against empty file path with [ -n "$f" ] check
- Use realpath to normalize paths before comparison, blocking
  path traversal via .. segments

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dqnykamp dqnykamp merged commit 8732ca4 into Doenet:main May 3, 2026
4 checks passed
@dqnykamp dqnykamp deleted the chore/auto-format-hook branch May 3, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants